Note
Click here to download the full example code
Plot pulsed simulation
This example demonstrates how to execute a pulsed simulation using ndk
import neurotechdevkit as ndk
scenario = ndk.built_in.Scenario0()
scenario.make_grid()
scenario.compile_problem()
result = scenario.simulate_pulse()
assert isinstance(result, ndk.results.PulsedResult2D)
result.render_pulsed_simulation_animation()
Out:
/home/circleci/.cache/pypoetry/virtualenvs/neurotechdevkit-3aSsmiER-py3.10/lib/python3.10/site-packages/devito/types/basic.py:613: DeprecationWarning: invalid escape sequence '\-'
"""
/home/circleci/.cache/pypoetry/virtualenvs/neurotechdevkit-3aSsmiER-py3.10/lib/python3.10/site-packages/pkg_resources/__init__.py:121: DeprecationWarning: pkg_resources is deprecated as an API
warnings.warn("pkg_resources is deprecated as an API", DeprecationWarning)
/home/circleci/.cache/pypoetry/virtualenvs/neurotechdevkit-3aSsmiER-py3.10/lib/python3.10/site-packages/pkg_resources/__init__.py:2870: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('mpl_toolkits')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
declare_namespace(pkg)
/home/circleci/.cache/pypoetry/virtualenvs/neurotechdevkit-3aSsmiER-py3.10/lib/python3.10/site-packages/pkg_resources/__init__.py:2870: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('sphinxcontrib')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
declare_namespace(pkg)
WARNING: DEVITO_ARCH environment variable not set and might cause compilation errors. See NDK documentation for help.
Estimated time to complete simulation: 2 minutes. Memory required is 28.92546936289519 GB (available 74.152890368 GB). These values are approximated.
Default Devito configuration:
* autotuning=off
* develop-mode=False
* mpi=False
* log-level=DEBUG
* language=openmp
(ShotID 0) Preparing to run state for shot
(ShotID 0) Estimated bandwidth for the propagated wavelet 0.257-0.724 MHz
(ShotID 0) Spatial grid spacing (0.500 mm | 4.145 PPW) is higher than dispersion limit (0.415 mm | 5.000 PPW)
(ShotID 0) Time grid spacing (0.083 μs | 46%) is above OT2 limit (0.080 μs) and below OT4 limit (0.145 μs)
(ShotID 0) Selected undersampling level 4
(ShotID 0) Selected time stepping scheme OT4
/home/circleci/.cache/pypoetry/virtualenvs/neurotechdevkit-3aSsmiER-py3.10/lib/python3.10/site-packages/devito/finite_differences/differentiable.py:224: DeprecationWarning: NotImplemented should not be used in a boolean context
return super(Differentiable, self).__eq__(other) and\
Operator `acoustic_iso_state` instance configuration:
* subs={h_x: 0.0005, h_y: 0.0005}
* opt=advanced
* platform=None
/home/circleci/.cache/pypoetry/virtualenvs/neurotechdevkit-3aSsmiER-py3.10/lib/python3.10/site-packages/devito/finite_differences/differentiable.py:224: DeprecationWarning: NotImplemented should not be used in a boolean context
return super(Differentiable, self).__eq__(other) and\
Operator `acoustic_iso_state` generated in 9.65 s
* lowering.Clusters: 4.44 s (46.1 %)
* specializing.Clusters: 2.89 s (30.0 %)
* lowering.Expressions: 2.84 s (29.5 %)
Flops reduction after symbolic optimization: [3457 --> 892]
recompiling for non-existent cache dir (/tmp/devito-codepy-uid1001/300b924/ae802b3a0a758d83087b6d6dfec378ed).
gcc -O3 -g -fPIC -Wall -std=c99 -march=native -Wno-unused-result -Wno-unused-variable -Wno-unused-but-set-variable -ffast-math -shared -fopenmp /tmp/devito-jitcache-uid1001/300b924d7d2dce0732c3931f2d6f9c3293d56c3f.c -lm -o /tmp/devito-jitcache-uid1001/300b924d7d2dce0732c3931f2d6f9c3293d56c3f.so
Operator `acoustic_iso_state` jit-compiled `/tmp/devito-jitcache-uid1001/300b924d7d2dce0732c3931f2d6f9c3293d56c3f.c` in 3.68 s with `GNUCompiler`
/home/circleci/.cache/pypoetry/virtualenvs/neurotechdevkit-3aSsmiER-py3.10/lib/python3.10/site-packages/numpy/ctypeslib.py:137: DeprecationWarning:
`numpy.distutils` is deprecated since NumPy 1.23.0, as a result
of the deprecation of `distutils` itself. It will be removed for
Python >= 3.12. For older Python versions it will remain present.
It is recommended to use `setuptools < 60.0` for those Python versions.
For more details, see:
https://numpy.org/devdocs/reference/distutils_status_migration.html
from numpy.distutils.misc_util import get_shared_lib_extension
/home/circleci/project/src/neurotechdevkit/rendering/_animations.py:118: UserWarning: You passed in an explicit save_count=127 which is being ignored in favor of frames=127.
anim = FuncAnimation(
Generating a video file
You can also generate a video file of the simulation (which requires ffmpeg installed).
To create and save the video as animation.mp4 in the current folder, all you
need is the execute following command:
Out:
/home/circleci/project/src/neurotechdevkit/rendering/_animations.py:118: UserWarning: You passed in an explicit save_count=127 which is being ignored in favor of frames=127.
anim = FuncAnimation(
Saved to animation.mp4 file.
Total running time of the script: ( 1 minutes 48.073 seconds)
Download Python source code: plot_pulsed_simulation.py